package createpattern.prototype.deepcopy.trueexample;

import createpattern.prototype.deepcopy.falseexample.Citation;
import createpattern.prototype.deepcopy.falseexample.Student;

import java.io.*;
/**
 * 深克隆 - 使用对象流
 * */
public class CitationTest {

    public static void main(String[] args) throws Exception {
        Citation c1 = new Citation();
        Student stu1 = new Student("张三", "广东");
        c1.setStu(stu1);

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("E:\\citation.txt"));
        oos.writeObject(c1);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("E:\\citation.txt"));
        Citation c2 = (Citation) ois.readObject();
        Student stu2 = c2.getStu();
        System.out.println(stu1 == stu2);

        c1.show();
        c2.show();
    }


}
